import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:yi_shop/components/mine/collect.dart';
import 'package:yi_shop/ui/keep_alive.dart';
import 'package:yi_shop/utils/colors.dart';
import 'package:yi_shop/utils/tools.dart';

class MineCollectController extends GetxController with GetSingleTickerProviderStateMixin {
  late TabController controller;
  List<String> tabs = ['商品', '店铺', '内容'];

  @override
  void onInit() {
    controller = TabController(length: tabs.length, vsync: this);
    super.onInit();
  }

  @override
  void onClose() {
    controller.dispose();
    super.onClose();
  }
}

class MineCollectPage extends GetView<MineCollectController> {
  const MineCollectPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        leading: ToolsUtils.builderLeading(color: ColorsUtils.parseColorFromHexString(ColorsUtils.color0000)),
        title: ToolsUtils.getClientTabBar(controller.tabs, controller.controller,
            isScrollable: false, indicatorSize: TabBarIndicatorSize.tab),
        systemOverlayStyle: SystemUiOverlayStyle.dark,
      ),
      body: TabBarView(
        controller: controller.controller,
        children: [
          KeepAliveWrapperTabView(
            child: const CollectProductView(),
            callback: () {
              Get.put(() => CollectProductController());
            },
          ),
          KeepAliveWrapperTabView(
            child: const CollectStoreView(),
            callback: () {
              Get.put(() => CollectStoreController());
            },
          ),
          KeepAliveWrapperTabView(
            child: const CollectContentView(),
            callback: () {
              Get.put(() => CollectContentController());
            },
          ),
        ],
      ),
    );
  }
}
